package com.star.mapper;

import com.github.pagehelper.Page;
import com.star.annotation.AutoFill;
import com.star.dto.BusinessPageQueryDTO;
import com.star.entity.Business;
import com.star.enumeration.OperationType;
import com.star.vo.user.BusinessVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface BusinessMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from business where username = #{username}")
    Business getByUsername(String username);

    /**
     * 新建员工
     * @param business
     */
    @Insert("insert into business (name, username, password, phone, id_number, " +
            "create_time, update_time, create_user, update_user, status)" +
            "values" +
            "(#{name}, #{username}, #{password}, #{phone}, #{idNumber}, #{createTime}, " +
            "#{updateTime}, #{createUser}, #{updateUser}, #{status})")
    @AutoFill(value = OperationType.INSERT)
    void insert(Business business);

    /**
     * 员工分页查询
     * @param businessPageQueryDTO
     * @return
     */
    Page<Business> pageQuery(BusinessPageQueryDTO businessPageQueryDTO);

    /**
     * 动态更新SQL
     * @param business
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Business business);

    /**
     * 根据id查询员工信息
     * @param id
     */
    @Select("select * from business where id = #{id}")
    Business getById(Long id);

    /**
     * C端商家查询
     * @param businessPageQueryDTO
     * @return
     */
    Page<BusinessVO> userPageQuery(BusinessPageQueryDTO businessPageQueryDTO);
}
